package pers.zc.activiti.shujujiegou.zhan;

/**
 * @description
 * @Author Lin FuYuan
 * @date 2020/5/12
 */
public class TestId {
    private static int id = 0;

    private static Object obj = new Object();
    public static long getId(){
        synchronized (obj) {
            id = id + 1;
            return (((long)(id & 0xFFFF)) << 32) | (((System.currentTimeMillis() / 1000) & 0x00000000FFFFFFFFL) << 16) | (id & 0x0000FFFF);
        }
    }

    public static void main(String[] args) {
        for (int i = 0; i <1000 ; i++) {
            System.out.println(getId());
        }
    }

}
